package app.modules.cloudpivot.function;

import java.util.Map;

import javax.annotation.Nonnull;

import com.authine.cloudpivot.metadata.bizmodel.RuleFunctionType;
import com.authine.cloudpivot.metadata.bizmodel.RuleParamType;
import com.authine.cloudpivot.metadata.history.bizmodel.RuleFunction;
import com.authine.cloudpivot.metadata.history.bizmodel.RuleFunctionBaseInfo;

/**
 * 自定义计算规则
 *
 * @author LiuGangQiang Create in 2025/11/12
 */
public class CustomRuleFunction extends RuleFunction {
    private static final long serialVersionUID = 5915572886031716975L;

    public String execute(Map<String, Object> env, String obj) {
        return obj.toLowerCase();
    }

    @Nonnull
    @Override
    public RuleFunctionBaseInfo getRuleFunctionBaseInfo() {
        return RuleFunctionBaseInfo.builder()
                .name("LOWERCASE")
                .fullName("LOWERCASE()")
                .displayName("LOWERCASE")
                .description("字符转小写")
                .instructions("字符转小写")
                .example("LOWERCASE(\"gfdsFABC\"),会返回gfdsfabc")
                .type(RuleFunctionType.TEXT)
                .returnType(RuleParamType.TEXT)
                .build();
    }
}
